package org.chl.chapter02;

import java.util.HashMap;
import java.util.Map;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyConfiguration implements WebMvcConfigurer  {

	public MyConfiguration() {
		System.out.println("----------------启动容器初始化spring-------------");
	}
	
	@Bean("nameMap")
	public Map<String, Object> nameMap() {
		Map<String, Object> nameMap = new HashMap<>();
		nameMap.put("chl", "陈宏亮");
		nameMap.put("diyee", "帝一");
		return nameMap;
	}
	
	
	/**
	 * 配置虚拟文件目录upload指向本地目录E:/basedir/work/Tomcat/localhost/upload
	 * @param registry
	 */
	@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
	        .addResourceHandler("/upload/**")
	        .addResourceLocations("file:E:/basedir/work/Tomcat/localhost/upload/");
        System.out.println("-----------------addResourceHandlers-------------------");
    }


}
